import Vue from 'vue'
import VueRouter from 'vue-router'
import FrameView from '../views/FrameView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'frame',
    component: FrameView,
    redirect: 'home',
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('@/views/HomeView.vue')
      },
      {
        path: '/about',
        name: 'about',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue'),
        children: [
          {
            path: 'detail/:id',
            name: 'detail',
            component: () => import('@/views/DetailView.vue')
          }
        ]
      },
      {
        path: '/book',
        name: 'books',
        component: () => import('@/views/BooksView.vue')
      }
    ]
  }

]

const router = new VueRouter({

  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
